<template>
  <!-- 作品详情 -->
  <div>
    <div class="comt">
      <el-card class="card">
        <h3>演员列表</h3>
        <div class="page">
          <div v-for="item in yy" :key="item.id">
            <img :src="baseurl + item.page" alt="演员" />
            <p class="name">{{ item.name }}</p>
          </div>
        </div>
        <h3>更多推荐</h3>
        <div class="commend">
          <div
            class="commend_car"
            v-for="item in tj"
            :key="item.id"
            @click="tiao(item.id)"
          >
            <img :src="baseurl + item.url" alt="图片" />
            <p>{{ item.name }}</p>
          </div>
        </div>
        <h3>相关视频</h3>
        <div class="comvio">
          <div v-for="item in xg" :key="item.id"  @click="tiao(item.id)">
            <img :src="baseurl + item.url" alt="图片" />
            <p class="name">{{ item.name }}</p>
          </div>
        </div>
      </el-card>
      <el-card class="siod">
        <h3>大家都在看</h3>
        <div v-for="item in dj" :key="item.id"  @click="tiao(item.id)">
          <img :src="baseurl + item.url" alt="图片" />
          <p>
            <span>{{ item.name }}</span>
          </p>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import { getyy, gdtj, getmovie, getjr } from "@/api/userone";
export default {
  data() {
    return {
      yy: [],
      baseurl: "http://127.0.0.1:7001",
      tj: [],
      xg: [],
      dj: [],
    };
  },
  created() {
    this.getdata();
  },
  methods: {
    getdata() {
      getyy().then((res) => {
        if (res.code == 0) {
          this.yy = res.data;
        }
      });
      gdtj().then((res) => {
        if (res.code == 0) {
          this.tj = res.data;
        }
      });
      getmovie(sessionStorage.getItem("id")).then((res) => {
        if (res.code == 0) {
          this.xg = res.data1;
        }
      });
      getjr().then((res) => {
        if (res.code == 0) {
          this.dj = res.data;
        }
      });
    },
    tiao(id) {
      sessionStorage.setItem("id", id);
      this.$router.push("/details");
    },
  },
};
</script>

<style lang="scss" scoped>
.comt {
  width: 1200px;
  margin: 0 auto;
  display: flex;
  .card {
    width: 880px;
    margin-right: 20px;
    .page {
      margin-top: 10px;
      display: flex;
      div {
        margin-left: 10px;
        img {
          width: 80px;
          height: 80px;
          border-radius: 50%;
          margin: 20px 10px 20px 0;
          object-fit: cover;
        }
        .name {
          width: 80px;
          text-align: center;
        }
      }
    }
    h3 {
      margin-top: 30px;
      margin-bottom: 20px;
    }
    .commend {
      margin-top: 10px;
      display: flex;
      justify-content: space-between;
      .commend_car {
        img {
          width: 150px;
          height: 200px;
        }
        p {
          color: #606266;
          width: 150px;
          text-align: center;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
    .comvio {
      display: flex;
      justify-content: flex-start;
      flex-wrap: wrap;
      div {
        margin-bottom: 20px;
        margin-right: 7px;
        margin-left: 10px;
        img {
          width: 150px;
          height: 200px;
        }
        .name {
          width: 150px;
          text-align: center;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
  .siod {
    width: 300px;
    height: 450px;
    div {
      margin-top: 20px;
      margin-left: 5px;
      float: left;
      img {
        width: 80px;
        height: 100px;
      }
      p {
        width: 80px;
        margin-bottom: 10px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
</style>